/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.jboss.seam.example.booking.action;

import javax.persistence.EntityManager;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.example.booking.entity.Hotel;
import org.jboss.seam.framework.Controller;

/**
 *
 * @author RHO
 */
@AutoCreate
@Name("hotelDeletePage")
@Scope(ScopeType.EVENT)
@Restrict("#{identity.loggedIn}")
public class HotelDeletePage extends Controller{
    
    @In
    private EntityManager entityManager;
    
    private String hotelId;

    public String getHotelId() {
        return hotelId;
    }

    public void setHotelId(String hotelId) {
        this.hotelId = hotelId;
    }
    
    public String doDelete() {
        System.out.println("hotelId"+hotelId);
        Hotel deleted = entityManager.find(Hotel.class, Long.parseLong(hotelId));
        entityManager.remove(deleted);
        return "show_hotel_list";
    }
    
}
